{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "09a897e7",
   "metadata": {},
   "outputs": [],
   "source": [
    "# eg1\n",
    "names = [\"Mike\",\"Mary\",\"Jan\",\"Jack\"]\n",
    "\n",
    "print(names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4d09962c",
   "metadata": {},
   "outputs": [],
   "source": [
    ">>> squares = [1, 4, 9, 16, 25]\n",
    ">>> squares\n",
    "[1, 4, 9, 16, 25]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e3f79196",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = \"lxx.xiaoming,xiaohong,xxl\"\n",
    "print(names[1])\n",
    "users_list = [\"lxx\",\"xiaoming\",\"xiaohong\",\"xxl\"]\n",
    "password_list = [123456,789654,178952,789456]\n",
    "age_list = [19,28,18,20]\n",
    "# ...\n",
    "# 列表的嵌套\n",
    "info_list = [\"lxx,123456,19\"]\n",
    "print(users_list)\n",
    "print(password_list)\n",
    "print(age_list)\n",
    "print(info_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1b6a92d3",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = [\"mike\",\"mary\",\"jan\",\"jack\"]\n",
    "# 知识点 slices（切片）数值是指values在list中的位置\n",
    "#1.正向取值\n",
    "# list 取值\":\"右边的值取不到 例如[1:3] 3这个位置取不到\n",
    "print(names[1:3])\n",
    "print(names[0:2])\n",
    "# 如果 左侧的值是0 即从0开始取值，0可以省略不写\n",
    "print(names[:2])\n",
    "\n",
    "#2.反向取值\n",
    "#list取值\":\"右边的值取不到 例如[-3:-1] -1 这个位置取不到\n",
    "# 注意  取到最后一个值，不能写 0 省略不写即可\n",
    "print(names[-3:1])\n",
    "num = [1,2,3,4,5,6,7,8,9]\n",
    "# 对比 range\n",
    "\n",
    "print(list(range(10)))\n",
    "print(num)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "129ca662",
   "metadata": {},
   "outputs": [],
   "source": [
    "name = input(\"name:\")\n",
    "age = input(\"age:\")\n",
    "job = input(\"job:\")\n",
    "salary = input(\"salary:\")\n",
    "\n",
    "info = '''----- INFO OF ''' + name +'''------''' + '''\n",
    "age:''' + age+'''\n",
    "job:''' + job +'''\n",
    "salary:'''+salary\n",
    "\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ded0140c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 用户输入方法2\n",
    "\n",
    "name = input(\"name:\")\n",
    "age = input(\"age:\")\n",
    "job = input(\"job:\")\n",
    "salary = input(\"salary:\")\n",
    "\n",
    "info = '''-------INFO OF %s -------\n",
    "Name:%s\n",
    "Age:%s\n",
    "Job:%s\n",
    "Salary:%s\n",
    "'''% (name,name,age,job,salary)\n",
    "\n",
    "print(info)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7ad17ef8",
   "metadata": {},
   "source": [
    "# %s代表 string\n",
    "\n",
    "# %d代表 number\n",
    "\n",
    "# %f代表 float"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "616c2ddd",
   "metadata": {},
   "outputs": [],
   "source": [
    "name = input(\"name:\")\n",
    "age = int(input(\"age:\"))  #注意！ python中默认所有的输入均为string\n",
    "job = input(\"job:\")\n",
    "salary = int(input(\"salary:\"))\n",
    " \n",
    "info = '''-------INFO OF %s -------\n",
    "Name:%s\n",
    "Age:%d\n",
    "Job:%s\n",
    "Salary:%d\n",
    "'''% (name,name,age,job,salary)\n",
    "\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f1af46be",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 假定你要求用户一2021-10-27格式输入\n",
    "user_input_time = \"2021-10-27\"\n",
    "# 字符串拆分，方法split"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3ac0b364",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 引入列表\n",
    "user_data_list = [[\"zhichao\",123435,19],[\"Jack\",463434,23],[\"Alex\",583495,25],[\"Marry\",438294,27]]\n",
    "# password_list = [123435,463434,583495,438294]\n",
    "# age = [19,23,25,27]\n",
    "# 1. 从左往右取值（index & slice）\n",
    "print(user_data_list[2])\n",
    "# 切片 slice ，右边的值取不到 例如[0:3] 索引为3的值取不到\n",
    "print(user_data_list[0:3])\n",
    "# 当从0开始取值时，0 可以忽略不写\n",
    "print(user_data_list[:3])\n",
    "\n",
    "# -3，-2，-1，0，1，2，3，4..\n",
    "# 2. 从右往左取值(index & slice)\n",
    "print(user_data_list[-2])\n",
    "# 切片 slice ，右边的值取不到 例如[-3:-1] 索引为-1的值取不到\n",
    "print(user_data_list[-3:-1])\n",
    "# 如果取值为空：说明slice写错了 例如[-3:0]\n",
    "# 如果要取到最后一个值，不能写0，直接省略不写\n",
    "print(user_data_list[-3:0])\n",
    "print(user_data_list[-3:])\n",
    "\n",
    "# ****重要****\n",
    "print(user_data_list[:])\n",
    "\n",
    "# 步长，list列表slice ：[start:stop:step]\n",
    "'''\n",
    "如果没有指定开始值，则默认为0；\n",
    "如果没有指定结束指，则取列表允许的最大值；\n",
    "如果没有指定步长值，则默认步长为1.\n",
    "'''\n",
    "num = list(range(10))\n",
    "print(num)\n",
    "print(num[0:6:2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d95462aa",
   "metadata": {},
   "outputs": [],
   "source": [
    "url = \"https://www.nfu.edu.cn/\"  #官网的域名\n",
    "# 目标获取高教动态的所有url链接\n",
    "高教动态 = \"gjdt\"\n",
    "url_页面 = \".htm\"\n",
    "url_页面细节不变 = \"/index\"\n",
    "\n",
    "# for i in range(1,27):\n",
    "#     完整的高教动态所有页面url = url+高教动态+ url_页面细节不变 + str(i)+url_页面\n",
    "#     print(完整的高教动态所有页面url)\n",
    "\n",
    "for i in range(1,27):\n",
    "    完整的高教动态所有页面url = \"https://www.nfu.edu.cn/{新闻}/index{页码}.htm\".format(页码=str(i),新闻=\"ztb\")\n",
    "    print(完整的高教动态所有页面url)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
